package com.itheima.controller;

import com.itheima.common.CommonResult;
import com.itheima.pojo.Blacklist;
import com.itheima.service.BlacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author wangjiexin
 */
@RestController
@RequestMapping("/user/blacklist")
public class BlacklistController {
    @Autowired
    BlacklistService blacklistService;
    //黑名单只有添加黑名单和删除黑名单
    //所以用post和delete就行了
    @PostMapping
    public CommonResult add(@RequestBody Blacklist blacklist){
        //添加用户黑名单
     boolean res =   blacklistService.add(blacklist);

     if (!res){
         return CommonResult.error("添加黑名单失败");
     }
        return CommonResult.success("添加黑名单成功",res);
    }

    @DeleteMapping
    public CommonResult del(@RequestParam String id){
        //传进来需要移除的id

      boolean result=  blacklistService.delete(id);
        if (!result){
            return CommonResult.error("删除黑名单失败");
        }

        return CommonResult.success("删除黑名单成功",result);
    }

    }


